/*
 * Author  : Pallab
 * Program : 10129
 *
 * 2012-03-23 17:19:50
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

template<class T1>
inline void debug(T1 _x) {
    cout<<_x<<'\n';
}
template<class T1, class T2>
inline void debug(T1 _x,T2 _y) {
    cout<<_x<<' '<<_y<<'\n';
}
template<class T1, class T2, class T3>
inline void debug(T1 _x,T2 _y,T3 _z) {
    cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
template<class T1, class T2, class T3, class T4>
inline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {
    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
template< class T1>
inline void debug(T1 _array,int _size) {
    cout<<"[";
    for (int i=0;i<_size;++i) {
        cout<<' '<<_array[i];
    }
    puts(" ]");
}
inline bool CI(int &_x) {
    return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
    return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
    return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}
const int inf = (int)30;
int root[ inf+10 ];
int rank[ inf+10 ];
inline void _Set() {
    foR(i,0,inf) {
        root[i]=i;
        rank[i]=0;
    }
}
inline int _Find(int x) {
    if ( x!= root[x] ) {
        root[x] = _Find(root[x]);
    }
    return root[x];
}
inline void _Union(int x, int y) {
    int rx = _Find(x);
    int ry = _Find(y);

    if ( rank[rx] > rank[ry] ) {
        root[ry] = rx;
    }
    else {
        root[rx] = ry;
    }
    if ( rank[rx]==rank[ry] ) {
        rank[ry]+=1;
    }
}
const int maxn=100005;
string words[maxn];
int n;
inline void Read() {
    CI(n);
    fo(i,n)cin>>words[i];
}
int in[30];
int out[30];
inline bool eular() {
    SET(in,0);
    SET(out,0);
    fo(i,n) {
        int a=words[i][0]-'a';
        int b=words[i][LN(words[i])-1]-'a';
        in[a]++;
        out[b]++;
    }
    int extra=0;
    fo(i,26) {
        int v=abs(in[i]-out[i]);
        if (v==0)continue;
        if (v>1)return false;
        if (v==1)++extra;
    }
    if (extra>2)return false;
    return true;
}
bitset<30> letters;
inline bool Connected() {
    _Set();
    int edges=0;
    letters=0;
    fo(i,n) {
        int a=words[i][0]-'a';
        int b=words[i][LN(words[i])-1]-'a';
        letters[a]=1;
        letters[b]=1;
        if (_Find(a)!=_Find(b)) {
            _Union(a,b);
            ++edges;
        }
    }
    int got=0;
    fo(i,26) {
        if (letters[i])++got;
    }
    if (edges!=got-1)return false;
    return true;
}
inline void Proc() {

    if (eular()) {
        if (Connected()) {
            puts("Ordering is possible.");
        }
        else {
            puts("The door cannot be opened.");
        }
    }
    else {
        puts("The door cannot be opened.");
    }
}
int main() {
    int tt;
    CI(tt);
    foE(i,1,tt) {
        Read();
        Proc();
    }
    return 0;
}
